<?php
/**
 * Created by JetBrains PhpStorm.
 * User: heimuya
 * Date: 14-1-26
 * Time: 下午1:33
 * 主页控制器类
 */
class TestAction extends AdminAction{
	
	public function _initialize(){
		parent::_initialize();
		$this->assign('page', __CLASS__);
	}
    /**
     * 后台首页
     */
    public function index(){
    	$where['uid'] = $_GET['uid'];
		$machineinfo = D('MachineView')->where($where)->select();
		dump($machineinfo);
		if(!$machineinfo){//机器未登记
			dump(array('status' => FALSE, 'code' => 1));
		}
		$user = array();
		$flag = FALSE;
		foreach ($machineinfo as $value) {
			if($value['nick'] == $_GET['user']){
				$flag = TRUE;
				$user = $value;
				break;
			}
		}
		if(!$flag){//用户不属于此机台
			dump(array('status' => FALSE, 'code' => 2));
		}
		if(strtolower($user['password']) !== strtolower($this->postdata['passwd'])){//用户密码错误
			dump(array('status' => FALSE, 'code' => 3));
		}
		//是否为有效用户
		if($user['valid'] !== 'y'){//用户被锁定，无法登陆，请联系管理员解锁
			dump(array('status' => FALSE, 'code' => 4));
		}
		else{//正常登陆
			dump(array('status' => TRUE, 'code' => 0));
		}
    }
}